﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Arich.Data;
using Arich.Data.GenericNHDal;
using NHibernate.Criterion;
using NHibernateDemo.DAL.Entity.ver2;
using NHibernate;
using NHibernate.Linq;
namespace NHibernateDemo.DAL {
    public class FundBasicDAL2 : AbstractDataManageDal<FundBasic2, string> {
        public IList<FundBasic2> SearchByDomicile(string domicile) {
            return GetByCriteria(null)
                .Add(Restrictions.Eq("Domicile", domicile))
                .SetFetchMode("ShareClasses", FetchMode.Eager)
                .SetMaxResults(10)
                .SetCacheable(true)
                .List<FundBasic2>( );

        }

        public IList<FundBasic2> SearchByDomicile(string domicile, int maxSize) {
            return NHibernateSession.Query<FundBasic2>( ).Where(p => p.Domicile == domicile).Take(maxSize).Cacheable().ToList( );
            //return
            //    NHibernateSessionManager.Instance.GetSession( ).CreateQuery(
            //        "from FundBasic2 f where f.Domicile = :name").SetString("name", domicile).SetCacheable(true).SetMaxResults(
            //            maxSize).List<FundBasic2>( );

        }
    }

    public class ShareClassBasicDAL : AbstractDataManageDal<ShareClassBasic, string> {

    }

    public class ShareClassBasicType : AbstractDataManageDal<ShareClassBasicType, string> {
    }
}
